package model

import (
	"database/sql"
	"time"

	"github.com/guregu/null"
	"github.com/satori/go.uuid"
)

var (
	_ = time.Second
	_ = sql.LevelDefault
	_ = null.Bool{}
	_ = uuid.UUID{}
)

/*
DB Table Details
-------------------------------------


CREATE TABLE "employees"
(
    [EmployeeId] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    [LastName] NVARCHAR(20)  NOT NULL,
    [FirstName] NVARCHAR(20)  NOT NULL,
    [Title] NVARCHAR(30),
    [ReportsTo] INTEGER,
    [BirthDate] DATETIME,
    [HireDate] DATETIME,
    [Address] NVARCHAR(70),
    [City] NVARCHAR(40),
    [State] NVARCHAR(40),
    [Country] NVARCHAR(40),
    [PostalCode] NVARCHAR(10),
    [Phone] NVARCHAR(24),
    [Fax] NVARCHAR(24),
    [Email] NVARCHAR(60),
    FOREIGN KEY ([ReportsTo]) REFERENCES "employees" ([EmployeeId])
		ON DELETE NO ACTION ON UPDATE NO ACTION
)

JSON Sample
-------------------------------------
{    "fax": "yKVgxEygoccYPJlQqmMxQWtDo",    "title": "AXRQVeJXkmohueBqGaLqiEmjF",    "reports_to": 29,    "birth_date": "2079-02-19T09:15:30.405273828+08:00",    "country": "wlixxsNmuDvigXXaelvZPnpNg",    "postal_code": "hWaUkfhCQIiIvweJwFbRhbSHW",    "first_name": "oqIqeJGWylJKqyjbCimgnroek",    "hire_date": "2304-01-20T19:06:51.170547703+08:00",    "city": "CLrdOCJNtGqFwdkcscAnqCJIW",    "state": "jYDVsnoEoITQTBXfZerCUJWDP",    "email": "dUpPFTgDyKQWUpyVAaiEDmIkC",    "employee_id": 66,    "last_name": "KvmdOEtxsGNkNpbxSiVnAjCSo",    "address": "uZUGGCfIXPZWTsUxEuYedjBWl",    "phone": "GBhIhLHYdRZFxwbWnwtZDypeD"}



*/

// Employees struct is a row record of the employees table in the main database
type Employees struct {
	//[ 0] EmployeeId                                     integer              null: false  primary: true   isArray: false  auto: true   col: integer         len: -1      default: []
	EmployeeID int32 `gorm:"primary_key;AUTO_INCREMENT;column:EmployeeId;type:integer;" json:"employee_id"`
	//[ 1] LastName                                       nvarchar(20)         null: false  primary: false  isArray: false  auto: false  col: nvarchar        len: 20      default: []
	LastName string `gorm:"column:LastName;type:nvarchar;size:20;" json:"last_name"`
	//[ 2] FirstName                                      nvarchar(20)         null: false  primary: false  isArray: false  auto: false  col: nvarchar        len: 20      default: []
	FirstName string `gorm:"column:FirstName;type:nvarchar;size:20;" json:"first_name"`
	//[ 3] Title                                          nvarchar(30)         null: true   primary: false  isArray: false  auto: false  col: nvarchar        len: 30      default: []
	Title sql.NullString `gorm:"column:Title;type:nvarchar;size:30;" json:"title"`
	//[ 4] ReportsTo                                      integer              null: true   primary: false  isArray: false  auto: false  col: integer         len: -1      default: []
	ReportsTo sql.NullInt64 `gorm:"column:ReportsTo;type:integer;" json:"reports_to"`
	//[ 5] BirthDate                                      datetime             null: true   primary: false  isArray: false  auto: false  col: datetime        len: -1      default: []
	BirthDate time.Time `gorm:"column:BirthDate;type:datetime;" json:"birth_date"`
	//[ 6] HireDate                                       datetime             null: true   primary: false  isArray: false  auto: false  col: datetime        len: -1      default: []
	HireDate time.Time `gorm:"column:HireDate;type:datetime;" json:"hire_date"`
	//[ 7] Address                                        nvarchar(70)         null: true   primary: false  isArray: false  auto: false  col: nvarchar        len: 70      default: []
	Address sql.NullString `gorm:"column:Address;type:nvarchar;size:70;" json:"address"`
	//[ 8] City                                           nvarchar(40)         null: true   primary: false  isArray: false  auto: false  col: nvarchar        len: 40      default: []
	City sql.NullString `gorm:"column:City;type:nvarchar;size:40;" json:"city"`
	//[ 9] State                                          nvarchar(40)         null: true   primary: false  isArray: false  auto: false  col: nvarchar        len: 40      default: []
	State sql.NullString `gorm:"column:State;type:nvarchar;size:40;" json:"state"`
	//[10] Country                                        nvarchar(40)         null: true   primary: false  isArray: false  auto: false  col: nvarchar        len: 40      default: []
	Country sql.NullString `gorm:"column:Country;type:nvarchar;size:40;" json:"country"`
	//[11] PostalCode                                     nvarchar(10)         null: true   primary: false  isArray: false  auto: false  col: nvarchar        len: 10      default: []
	PostalCode sql.NullString `gorm:"column:PostalCode;type:nvarchar;size:10;" json:"postal_code"`
	//[12] Phone                                          nvarchar(24)         null: true   primary: false  isArray: false  auto: false  col: nvarchar        len: 24      default: []
	Phone sql.NullString `gorm:"column:Phone;type:nvarchar;size:24;" json:"phone"`
	//[13] Fax                                            nvarchar(24)         null: true   primary: false  isArray: false  auto: false  col: nvarchar        len: 24      default: []
	Fax sql.NullString `gorm:"column:Fax;type:nvarchar;size:24;" json:"fax"`
	//[14] Email                                          nvarchar(60)         null: true   primary: false  isArray: false  auto: false  col: nvarchar        len: 60      default: []
	Email sql.NullString `gorm:"column:Email;type:nvarchar;size:60;" json:"email"`
}

var employeesTableInfo = &TableInfo{
	Name: "employees",
	Columns: []*ColumnInfo{

		{
			Index:              0,
			Name:               "EmployeeId",
			Comment:            ``,
			Notes:              ``,
			Nullable:           false,
			DatabaseTypeName:   "integer",
			DatabaseTypePretty: "integer",
			IsPrimaryKey:       true,
			IsAutoIncrement:    true,
			IsArray:            false,
			ColumnType:         "integer",
			ColumnLength:       -1,
			GoFieldName:        "EmployeeID",
			GoFieldType:        "int32",
			JSONFieldName:      "employee_id",
			ProtobufFieldName:  "employee_id",
			ProtobufType:       "int32",
			ProtobufPos:        1,
		},

		{
			Index:              1,
			Name:               "LastName",
			Comment:            ``,
			Notes:              ``,
			Nullable:           false,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(20)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       20,
			GoFieldName:        "LastName",
			GoFieldType:        "string",
			JSONFieldName:      "last_name",
			ProtobufFieldName:  "last_name",
			ProtobufType:       "string",
			ProtobufPos:        2,
		},

		{
			Index:              2,
			Name:               "FirstName",
			Comment:            ``,
			Notes:              ``,
			Nullable:           false,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(20)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       20,
			GoFieldName:        "FirstName",
			GoFieldType:        "string",
			JSONFieldName:      "first_name",
			ProtobufFieldName:  "first_name",
			ProtobufType:       "string",
			ProtobufPos:        3,
		},

		{
			Index:              3,
			Name:               "Title",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(30)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       30,
			GoFieldName:        "Title",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "title",
			ProtobufFieldName:  "title",
			ProtobufType:       "string",
			ProtobufPos:        4,
		},

		{
			Index:              4,
			Name:               "ReportsTo",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "integer",
			DatabaseTypePretty: "integer",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "integer",
			ColumnLength:       -1,
			GoFieldName:        "ReportsTo",
			GoFieldType:        "sql.NullInt64",
			JSONFieldName:      "reports_to",
			ProtobufFieldName:  "reports_to",
			ProtobufType:       "int32",
			ProtobufPos:        5,
		},

		{
			Index:              5,
			Name:               "BirthDate",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "datetime",
			DatabaseTypePretty: "datetime",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "datetime",
			ColumnLength:       -1,
			GoFieldName:        "BirthDate",
			GoFieldType:        "time.Time",
			JSONFieldName:      "birth_date",
			ProtobufFieldName:  "birth_date",
			ProtobufType:       "google.protobuf.Timestamp",
			ProtobufPos:        6,
		},

		{
			Index:              6,
			Name:               "HireDate",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "datetime",
			DatabaseTypePretty: "datetime",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "datetime",
			ColumnLength:       -1,
			GoFieldName:        "HireDate",
			GoFieldType:        "time.Time",
			JSONFieldName:      "hire_date",
			ProtobufFieldName:  "hire_date",
			ProtobufType:       "google.protobuf.Timestamp",
			ProtobufPos:        7,
		},

		{
			Index:              7,
			Name:               "Address",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(70)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       70,
			GoFieldName:        "Address",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "address",
			ProtobufFieldName:  "address",
			ProtobufType:       "string",
			ProtobufPos:        8,
		},

		{
			Index:              8,
			Name:               "City",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(40)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       40,
			GoFieldName:        "City",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "city",
			ProtobufFieldName:  "city",
			ProtobufType:       "string",
			ProtobufPos:        9,
		},

		{
			Index:              9,
			Name:               "State",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(40)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       40,
			GoFieldName:        "State",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "state",
			ProtobufFieldName:  "state",
			ProtobufType:       "string",
			ProtobufPos:        10,
		},

		{
			Index:              10,
			Name:               "Country",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(40)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       40,
			GoFieldName:        "Country",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "country",
			ProtobufFieldName:  "country",
			ProtobufType:       "string",
			ProtobufPos:        11,
		},

		{
			Index:              11,
			Name:               "PostalCode",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(10)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       10,
			GoFieldName:        "PostalCode",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "postal_code",
			ProtobufFieldName:  "postal_code",
			ProtobufType:       "string",
			ProtobufPos:        12,
		},

		{
			Index:              12,
			Name:               "Phone",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(24)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       24,
			GoFieldName:        "Phone",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "phone",
			ProtobufFieldName:  "phone",
			ProtobufType:       "string",
			ProtobufPos:        13,
		},

		{
			Index:              13,
			Name:               "Fax",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(24)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       24,
			GoFieldName:        "Fax",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "fax",
			ProtobufFieldName:  "fax",
			ProtobufType:       "string",
			ProtobufPos:        14,
		},

		{
			Index:              14,
			Name:               "Email",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(60)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       60,
			GoFieldName:        "Email",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "email",
			ProtobufFieldName:  "email",
			ProtobufType:       "string",
			ProtobufPos:        15,
		},
	},
}

// TableName sets the insert table name for this struct type
func (e *Employees) TableName() string {
	return "employees"
}

// BeforeSave invoked before saving, return an error if field is not populated.
func (e *Employees) BeforeSave() error {
	return nil
}

// Prepare invoked before saving, can be used to populate fields etc.
func (e *Employees) Prepare() {
}

// Validate invoked before performing action, return an error if field is not populated.
func (e *Employees) Validate(action Action) error {
	return nil
}

// TableInfo return table meta data
func (e *Employees) TableInfo() *TableInfo {
	return employeesTableInfo
}
